// MyTrayTool.cpp: implementation of the CMyTrayTool class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "MyTrayTool.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif


//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CMyTrayTool::CMyTrayTool()
{

}

CMyTrayTool::~CMyTrayTool()
{
	m_nid.hIcon = NULL;
	Shell_NotifyIcon (NIM_DELETE, &m_nid);
}

void CMyTrayTool::Init(HICON hIcon, HWND hMsgWnd, LPCTSTR strTip)
{
	// Initialize NOTIFYICONDATA
	memset(&m_nid, 0 , sizeof(m_nid));
	m_nid.cbSize = sizeof(m_nid);
	m_nid.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE;
	
	//m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
	m_hIcon = hIcon;
	
//	SetIcon(m_hIcon, TRUE);			// Set big icon
//	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// Set tray notification window:
	m_nid.hWnd = hMsgWnd;
	m_nid.uCallbackMessage = MYMESSAGE_TRAY;
	
	// Set tray icon and tooltip:
	m_nid.hIcon = m_hIcon;
	
	CString strToolTip = strTip;//_T("BCGSideBar Demo");
	strncpy (m_nid.szTip, strToolTip, strToolTip.GetLength());
	
	Shell_NotifyIcon (NIM_ADD, &m_nid);	
}

